package org.goldenport.g3.sample

import org.goldenport.g3._
import org.goldenport.g3.messages._
import org.goldenport.g3.messages.entity._

/**
 * @since   Aug. 27, 2010
 * @version Sep.  6, 2010
 * @author  ASAMI, Tomoharu
 */
class ViewSetup extends G3Application with UseRecord {
  entityspace('myds, new BookEntityDriver(""))

  val drop = MsgAnd(Drop(BookEntitySpace.KIND_BOOK),
                    Drop(BookEntitySpace.KIND_AUTHOR),
                    Drop(BookEntitySpace.KIND_PUBLISHER),
                    Drop(BookEntitySpace.KIND_PUBLISH))

  val create = MsgAnd(Create(BookEntitySpace.KIND_BOOK),
                      Create(BookEntitySpace.KIND_AUTHOR),
                      Create(BookEntitySpace.KIND_PUBLISHER),
                      Create(BookEntitySpace.KIND_PUBLISH))

  val insert = MsgAnd(Insert(BookEntitySpace.KIND_PUBLISHER,
                             Record('id -> 10, 'name -> "ABC Publication")),
                      Insert(BookEntitySpace.KIND_AUTHOR,
                             Record('id -> 700, 'name -> "Yamada Taro")),
                      Insert(BookEntitySpace.KIND_BOOK,
                             Record('id -> 5, 'name -> "My book",
                                    'author -> 700,
                                    'publisher -> 10)),
                      Insert(BookEntitySpace.KIND_PUBLISH,
                             Record('id -> 1111,
                                    'date -> VDate(),
                                    'book -> 5,
                                    'author -> 700,
                                    'publisher -> 10)))

  start(MsgSeq(drop, create, insert)) invoke("myds")
}
